﻿package src.panel 
{
	import flash.display.DisplayObject;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event
	import flash.net.URLRequest;
	/**
	 * ...
	 * @author keys_star@163.com
	 */
	public class imagePanel extends Sprite
	{
		private var loadr:Loader
		public function imagePanel() 
		{
		}
		public function set image(u:String):void {
			load(u);
		}
		private function load(u:String) {
			try { removeChild(loadr) } catch (e:Error) { }
			loadr = new Loader;
			loadr.contentLoaderInfo.addEventListener(Event.COMPLETE, lcom);
			
			var req:URLRequest = new URLRequest(u);
			loadr.load(req);
			addChild(loadr);
		}
		private function lcom(e:Event) {
			var mc:DisplayObject = e.target.content;
			mc.x = -mc.width / 2;
			mc.y = -mc.height / 2;
		}
	}
	
}